<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <h2>这是注册页面</h2>
    用户名：<input type="text" value="" id="username"><br>
    密码：<input type="text" value="" id="password"><br>
    <input type="button" value="注册" id="btn">
</body>
<script src="./js/jquery.js"></script>
<script>
    $("#btn").on("click",function(){
        $.ajax({
            url:"http://localhost:3000/api",
            data:{
                type:"register",
                username:$("#username").val(),
                password:$("#password").val()
            },
            success:res=>{
                console.log(res)
                res = JSON.parse(res);
                if(res.code === 1){
                    if(confirm("注册成功，是否跳转到登录？")){
                        location.href = "./login.html"
                    }
                }else{
                    alert(res.title);
                }
            }
        })
    })
</script>
</html>